package com.roc.web.action.agent;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class ProfitModuleSearchCondition extends BaseSearchCondition {
/**
	 * 
	 */
	private static final long serialVersionUID = -1441229972966708081L;

	/*
	private String 	minDate; // 交易开始时间(年月日)
	private String 	maxDate; // 交易结束时间(年月日)
*/	
	private String modelName;
	
	private Long agentId;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {

		return " order by t.DT_CREATE desc ";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
		
		sb.append( " SELECT COUNT(1) FROM T_PROFIT_MODULE t WHERE 1 = 1 " );
		
		return sb.toString();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		StringBuffer sb = new StringBuffer();
		
		sb.append( " SELECT  T.ID , T.MODULE_NAME , T.REMARK , T.DT_CREATE , T.STATUS " );
		sb.append( " FROM T_PROFIT_MODULE T WHERE 1 = 1 " );
		
		return sb.toString();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		if (Constance.isNotEmpty(modelName)) {
			filedBeanList.add(new WhereHQLFieldBean("T.MODULE_NAME", modelName.trim()
					.trim(), "=", false));
		}
		if(agentId != 0 || agentId != null){
			filedBeanList.add(new WhereHQLFieldBean("T.AGENT_ID",agentId,"=",false));
		}
		return filedBeanList;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public Long getAgentId() {
		return agentId;
	}

	public void setAgentId(Long agentId) {
		this.agentId = agentId;
	}

}
